/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.google.common.base.Charsets;
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxIndex;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.io.ByteArrayOutputStream;
/*    */ import java.io.PrintStream;
/*    */ import java.io.UnsupportedEncodingException;
/*    */ import java.nio.charset.Charset;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public final class VerifyIndex
/*    */   extends AdminDocumentHandler
/*    */ {
/* 47 */   private static final String[] TARGET_ACCOUNT_PATH = { "mbox", "id" };
/*    */   
/*    */ 
/*    */ 
/*    */   protected String[] getProxiedAccountPath()
/*    */   {
/* 53 */     return TARGET_ACCOUNT_PATH;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map<String, Object> context)
/*    */   {
/* 61 */     return true;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 66 */     relatedRights.add(Rights.Admin.R_reindexMailbox);
/* 67 */     relatedRights.add(Rights.Admin.R_reindexCalendarResourceMailbox);
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 73 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 74 */     Element mreq = request.getElement("mbox");
/* 75 */     String accountId = mreq.getAttribute("id");
/*    */     
/* 77 */     Provisioning prov = Provisioning.getInstance();
/* 78 */     Account account = prov.get(Key.AccountBy.id, accountId, zsc.getAuthToken());
/* 79 */     if (account == null) {
/* 80 */       throw AccountServiceException.NO_SUCH_ACCOUNT(accountId);
/*    */     }
/*    */     
/* 83 */     Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
/* 84 */     if (mbox == null) {
/* 85 */       throw ServiceException.FAILURE("mailbox not found for account " + accountId, null);
/*    */     }
/*    */     
/* 88 */     ByteArrayOutputStream out = new ByteArrayOutputStream();
/* 89 */     boolean status = mbox.index.verify(new PrintStream(out));
/* 90 */     Element resp = zsc.createElement(AdminConstants.VERIFY_INDEX_RESPONSE);
/* 91 */     resp.addElement("status").addText(String.valueOf(status));
/*    */     try
/*    */     {
/* 94 */       resp.addElement("message").addText(out.toString(Charsets.UTF_8.name()));
/*    */     } catch (UnsupportedEncodingException never) {
/* 96 */       if (!$assertionsDisabled) { throw new AssertionError();
/*    */       }
/*    */     }
/* 99 */     return resp;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/VerifyIndex.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */